package net.bolue.web.mvc;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import net.bolue.console.model.DeleteModel;
import net.bolue.sysmng.exception.BolueException;
import net.bolue.sysmng.model.DelResModel;
import net.bolue.sysmng.tblbean.DelRes;
import net.bolue.web.report.RepConstants;
import net.bolue.web.util.RequestUtil;

/**
 * 删除操作业务
 * @author Administrator
 *
 */
public class DeleteAction extends AbstractAction {

	@Override
	public ActionResult perform(HttpServletRequest request, HttpServletResponse response) throws BolueException{
		String subSys = RequestUtil.getParamValue(request, RepConstants.REP_SUBSYS_KEY);
		String deleteID = RequestUtil.getParamValue(request, RepConstants.REP_DELETE_KEY);
		if(subSys==null || subSys.trim().length()==0 || deleteID==null || deleteID.trim().length()==0){
			throw new BolueException(5, "处理删除操作时，必须提供request参数subSys,deleteID！");
		}
		
		DelResModel delResModel = new DelResModel(request);
		DelRes delRes = delResModel.getDelRes(subSys, deleteID);
		if(delRes==null){
			throw new BolueException(10, "没有找到subSys="+subSys+",deleteID="+deleteID+"的删除记录资源！");
		}
		DeleteModel deleteModel = new DeleteModel(request,delRes);
		return deleteModel.delete();
	}

}
